using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DAL;
using BLL;
using DTO;

namespace WellmeadowsHospital
{
    public partial class frmSearchAppointment : DevExpress.XtraEditors.XtraUserControl
    {
        AppointmentBLL appointmentBLL = new AppointmentBLL();
        StaffBLL staffBLL = new StaffBLL();
        PatientBLL patientBLL = new PatientBLL();

        public frmSearchAppointment()
        {
            InitializeComponent();
            gcAppointListinSearchAppointH.DataSource = appointmentBLL.SelectAll();
        }

        private void txtSearchAppointinSearchAppointH_KeyPress(object sender, KeyPressEventArgs e)
        {
            string key = txtSearchAppointinSearchAppointH.Text;
            if (!key.Equals(""))
            {
                gcAppointListinSearchAppointH.DataSource = appointmentBLL.SearchwithStafforPatient(key);
            }
            else
            {
                gcAppointListinSearchAppointH.DataSource = appointmentBLL.SelectAll();
            }
        }

        private void gridView7_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            string staffid = gridView7.GetRowCellValue(gridView7.GetSelectedRows()[0], gcolStaffIDinSearchH).ToString();
            string patientid = gridView7.GetRowCellValue(gridView7.GetSelectedRows()[0], gcolPatientIDinSearchH).ToString();
            gcStaffinSearchAppointH.DataSource = staffBLL.Search(staffid);
            gcPatientinSearchAppointH.DataSource = patientBLL.Search(patientid);
        }
    }
}
